import java.util.*;
import java.util.Stack;

public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.push(9);
        solution.push(1);
        solution.push(6);
        solution.min();

        solution.pop();
        solution.pop();
        solution.min();


    }

    int[] nums = new int[300];
    int count = 0;//栈中元素个数,并且可以表示即将可以写入的下标
    int len = nums.length;//整个数组的长度：300


    public void push(int node) {
        //栈不满
        if(count<len){
            nums [count] = node;
            count++;
        }
    }

    public void pop() {
        if(count>0){
            System.out.println(nums[count-1]);
            count--;
        }
    }

    public int top() {
        if(count>0){
            //System.out.println(nums[count-1]);
            return nums[count-1];
        }
        return -1;
    }

    public int min() {
        int[] nums2 = new int[count];
        int count2 = count;
        int min = this.top();
        for(int i = count -1;i>=0;i--){
            int top = this.top();
            //this.pop();
            count--;
            if(min>top){
                min = top;
            }
            //nums2[i]=top;
            //nums2.push(top);
            nums2[count2-1-i]=top;
        }
        for(int i = count2-1;i>=0;i--){
            this.push(nums2[i]);
        }
        return min;
    }
}
